package com.self.smallma.myblogweb.exception;

import com.self.smallma.myblogweb.common.utils.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 集中处理所有异常
 */
@Slf4j
//@ResponseBody
//@ControllerAdvice(basePackages = "com.self.smallma.myblogweb.web")
@RestControllerAdvice(basePackages = "com.self.smallma.myblogweb.web")
public class ExceptionControllerAdvice {


    @ExceptionHandler(value = Exception.class)
    public R handleVaildException(Exception e){
        log.error("数据校验出现异常:{}，异常类型:{}",e.getMessage(),e.getClass());
        return R.error();
    }
}
